package cn.com.dealme.domain.repository.impl;

import java.util.List;

import org.hibernate.Session;

import cn.com.dealme.domain.model.PublishMode;
import cn.com.dealme.domain.persistence.CatagoryPersistenceProxy;
import cn.com.dealme.domain.persistence.PublishModePersistenceProxy;
import cn.com.dealme.domain.repository.IPublishModeRepository;

public class PublishModeRepositoryImpl implements IPublishModeRepository {
	
	private Session session;

	public void delete(Long id) {
		session.delete(session.get(PublishModePersistenceProxy.class, id));
	}

	public PublishMode find(Long id) {
		return (PublishMode) session.get(PublishModePersistenceProxy.class, id);
	}

	@SuppressWarnings("unchecked")
	public List<PublishMode> listAll() {
		String entityName = session.getSessionFactory().getClassMetadata(
				CatagoryPersistenceProxy.class).getEntityName();
		return session.createQuery("from " + entityName).list();
	}

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	
}
